gtk/icon-theme: Handle lack of SVG loader gracefully
authorJonas Ådahl <jadahl@gmail.com>
Wed, 7 Aug 2019 17:20:46 +0000 (19:20 +0200)
committerJonas Ådahl <jadahl@gmail.com>
Thu, 8 Aug 2019 07:05:30 +0000 (09:05 +0200)
When loading a SVG icon from a gresource file only containing SVG icons,
but without having a SVG loader available in gdk-pixbuf, we would crash
when trying to eventually load the resource. Fix this by gracefully
handling this by simply failing to load the icon, while the first time
it happens, log a warning.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/2084
gtk/gtkicontheme.c

index 117ccceb120aba69812011665cc0de25347048e1..df13afc5b8ec73cedc9bb0264afce02219c07d92 100644 (file)
@@ -1768,6 +1768,20 @@ real_choose_icon (GtkIconTheme       *icon_theme,
         icon_info->filename = g_strdup (unthemed_icon->svg_filename);
       else if (unthemed_icon->no_svg_filename)
         icon_info->filename = g_strdup (unthemed_icon->no_svg_filename);
+      else
+        {
+          static gboolean warned_once = FALSE;
+
+          if (!warned_once)
+            {
+              g_warning ("Found an icon but could not load it. "
+                         "Most likely gdk-pixbuf does not provide SVG support.");
+              warned_once = TRUE;
+            }
+
+          g_clear_object (&icon_info);
+          goto out;
+        }
 
       if (unthemed_icon->is_resource)
         {